import type { RequestConfig } from 'sula/es/types/request';
import request from 'umi-request';

export const getProgramListConfig = (): RequestConfig => {
    return {
        url: '/question/code',
        method: 'GET',
        convertParams: (ctx) => {
            let params = { ...ctx.params };
            params = params.filters
            return params;
        },
        converter: ({ data }) => {
            return {
                list: data
            }
        }
    };
};

// 执行编程题
export const excute = async (data: any) => {
    return request<any>('/code/check', {
        method: 'POST',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

// 获取编程题结果
export const getScriptResult = async (data: any) => {
    return request<any>('/code/checkStatus', {
        method: 'GET',
        params: { codeId: data },
    });
};